const http = require('http');
const fs = require('fs')

const server = http.createServer();

server.on('request', function (req, res) {
    res.writeHead(200,{
        'Content-Type':'text/html',
        'Access-Control-Allow-Origin': '*'
    })
    fs.readFile('./index.html', 'utf-8', function (err, data) {
        if (err) {
            throw err;
        }
        res.end(data);

    })
})


server.listen(8888);

// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');